<template>
  <van-button type="success" @click="Login">微信授权登录</van-button>
</template>

<script>
import MyAxios from "@/plugins/MyAxios";
import { ref } from "vue";

export default {
  setup() {
    const Login = () => {
      const local = "http://192.168.1.30:80/api/user/login/wx_open";
      const wechatAuthUrl =
        "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxbe0ad239ce07912b&redirect_uri=" +
        encodeURIComponent(local) +
        "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
      window.location.href = wechatAuthUrl;

      const userCode = window.location.search;
      console.log(userCode);
      // MyAxios.get("/user/login/wx_open", {
      //   params: { code: userCode },
      // }).then((response) => {
      //   console.log(response);
      // });
    };
    return {
      Login,
    };
  },
};
</script>

<style scoped></style>
